package com.hanbang.qzzds.appliction.base.presenter;

import com.hanbang.qzzds.appliction.base.view.IListView;
import com.hanbang.qzzds.mode.httpresponse.HttpResult;
import com.hanbang.qzzds.utils.http.HttpCallBack;

import java.util.List;

/**
 * Created by Administrator on 2016/8/8.
 */

public class ListPresenter extends BasePresenter<IListView> {
    //请求的Http方法
    enum ApiType {
        ONE
    }


    public void getHttpData(final boolean isStart, ApiType apiType) {
        if (isStart) {
            mvpView.clearPagingData();
        }
        mvpView.getLoadingAndRetryManager();
        HttpCallBack.Buider buider = new HttpCallBack.Buider(this).setShowLoadding(false).setLoadingAndRetryManager(mvpView.getLoadingAndRetryManager()).
                setStatusChangListener(mvpView.getStatusChangListener()).setSwipeRefreshLayout(mvpView.getSwipeRefreshLayout());
        final HttpCallBack httpCallBack = new HttpCallBack<HttpResult<List>>(buider) {
            @Override
            public void onNext(HttpResult<List> result) {
                super.onNext(result);
                //进行data处理
                if (result.isSucceed()) {
                    if (isStart) {
                        mvpView.clearData();
                    }
                    mvpView.upDataUi((List) mvpView.getValidData(result.getData()));
                }
            }
        };
//        HttpRequest.ChefMoreThan(httpCallBack, "rJDF+FKr/+QFmKYOrdB5Nw==", "lltbO3/sQJIfwXD8Zf0VWA==", 0, mvpView.getPageindex(), mvpView.getPageCount());
    }


}
